package com.v2.k1;


import org.springframework.beans.factory.support.AbstractBeanDefinition;
import org.springframework.beans.factory.support.BeanDefinitionBuilder;
import org.springframework.beans.factory.support.DefaultListableBeanFactory;

/**
 * 测试beanDefinition创建一个bean
 * 测试BeanFactory   DefaultListableBeanFactory
 */
public class TestBeanDefinition {

	public static void main(String[] args) {

		AbstractBeanDefinition beanDefinition = BeanDefinitionBuilder.genericBeanDefinition().getBeanDefinition();
		beanDefinition.setBeanClass(User.class);

		DefaultListableBeanFactory beanFactory = new DefaultListableBeanFactory();
		beanFactory.registerBeanDefinition("user", beanDefinition);
		System.out.println(beanFactory.getBean("user"));

		beanFactory.registerBeanDefinition("user", beanDefinition);
		System.out.println(beanFactory.getBean("user"));

		System.out.println(beanFactory.getBean("user"));

	}

}
